<template>
  <div>
    <el-card>
      <div slot="header" class="clearfix">
        <span>退款待审核订单列表</span>
      </div>
      <el-table
        :data="tableData"
        style="width: 100%">
        <el-table-column
          type="index"
          :index="indexMethod"
          label="序号"
          width="180">
        </el-table-column>

        <el-table-column
          label="订单ID"
          width="180">
          <template slot-scope="scope">
            <el-popover trigger="hover" placement="top">
              <p>支付方法: {{ scope.row.paymentMethod }}</p>
              <p>支付账户: {{ scope.row.paymentAccount }}</p>
              <p>支付人: {{ scope.row.paymentUser }}</p>
              <div slot="reference" class="name-wrapper">
                <el-tag size="medium">{{ scope.row.orderDetailId }}</el-tag>
              </div>
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column
          label="用户名"
          width="180">
          <template slot-scope="scope">
            <span style="margin-left: 10px">{{ scope.row.username }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="商品名称"
          width="180">
          <template slot-scope="scope">
            <span style="margin-left: 10px">{{ scope.row.productName }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="商品价格"
          width="180">
          <template slot-scope="scope">
            <span style="margin-left: 10px">{{ scope.row.price }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="danger"
              @click="open(scope.row.orderDetailId)">退款审核通过</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>

  </div>


</template>

<script>
  export default {
    data() {
      return {
        tableData: []
      }
    },
    mounted() {
      this.init();
    },
    methods: {
      handleDelete(index, row) {
        console.log(index, row);
      },
      indexMethod(index) {
        return index+1 ;
      },
      init:function() {
        this.$axios({
          headers:{
            "Content-Type": "application/json"
          },
          methods: "post",
          url:"http://localhost:8080/api/order/refundAuditOrder",
          data:{}
        }).then((res)=>{
          console.log(res.data);
          if(res.data.resultCode==="0"){
            this.tableData= res.data.orderDetailViewList;

          }
        }).catch((error)=>{
          console.log(error);
        })

      },
      open(orderDetailId) {
        this.$confirm('确定通过审核？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          width:80,
          center:true
        }).then(() => {
          this.deleteuser(orderDetailId)
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消发货'
          });
        });
      },
      deleteuser:function(orderDetailId) {
        const dd={orderDetailId:orderDetailId}
        // console.log(id)
        this.$axios({
          headers:{
            "Content-Type":"application/json"
          },
          method: "post",
          url:"http://localhost:8080/api/order/updaterefundAudit",
          data:{
            orderDetailId:dd.orderDetailId
          }
        }).then((res)=>{
          if(res.data.resultCode==="0"){
            this.$message({
              message: '退款审核成功',
              type: 'success'
            })
            this.init()
          }
        }).catch((error)=>{
          console.log(error);
        })
      }
    }
  }
</script>

<style scoped>

</style>
